package cn.com.homeyoda.aimate.aihealth.ui.message;

import android.content.Context;
import android.graphics.Typeface;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.MessageTypeListBean;

/**
 * Created By 刘纯贵
 * Created Time 2020/4/30
 */
public class MessageTypeAdapter extends BaseQuickAdapter<MessageTypeListBean.DataBean, BaseViewHolder> {

    private int selectPos = 0;
    private Context mContext;
    public MessageTypeAdapter(int layoutResId, @Nullable List<MessageTypeListBean.DataBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MessageTypeListBean.DataBean item) {

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.setText(R.id.title,getData().get(position).getTypeName());

        TextView tvTitle = holder.getView(R.id.title);
        if(selectPos == position){
            tvTitle.setTypeface(null, Typeface.BOLD);
            holder.setTextColor(R.id.title,mContext.getResources().getColor(R.color.colorPrimary));
            holder.setVisible(R.id.view,true);
        }else{
            tvTitle.setTypeface(null, Typeface.NORMAL);
            holder.setTextColor(R.id.title,mContext.getResources().getColor(R.color.black));
            holder.setVisible(R.id.view,false);
        }
    }

    public void setPos(int pos){
        selectPos = pos;
        notifyDataSetChanged();
    }

    @Override
    public void setNewData(@Nullable List<MessageTypeListBean.DataBean> data) {
        super.setNewData(data);
    }
}
